﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Common.Helpers
{
    /// <summary>
    /// MD5Helper 
    /// </summary>
    public class MD5Helper
    {
        /// <summary>
        /// MD5大写
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string GetMd5HashToUppercase(string input)
        {
            using (MD5 md5 = MD5.Create())
            {
                byte[] data = Encoding.UTF8.GetBytes(input);
                byte[] hash = md5.ComputeHash(data);
                // 转换为32位十六进制字符串（大写）
                return BitConverter.ToString(hash).Replace("-", "");
            }
        }

        /// <summary>
        /// MD5小写
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static string GetMd5HashLowercase(string input)
        {
            return GetMd5HashToUppercase(input).ToLower();
        }
    }
}
